import { http } from '@/utils/http'

/**
 * 获取农事分类
 * @returns Promise<IResData<IRecordType[]>>
 */
export function recordType(): Promise<IResData<IRecordType[]>> {
  return http.get('/api/nongshang/record_type')
}

/**
 * 提交农事记录
 * @param params IRecordSubmit
 * @return Promise<IResData<any>>
 */
export function recordSubmit(params: IRecordSubmit): Promise<IResData<any>> {
  return http.post('/api/nongshang/record_submit', params, params)
}

/**
 * 年度支出金额
 * @params year string
 */
export function recordYearAmount(year: string): Promise<IResData<any>> {
  return http.get(`/api/nongshang/amount`, { year })
}

/**
 * 农事记录汇总
 * @params
 */
export function recordSummary(params: IRecordSummary): Promise<IResData<IPageRes<IRecord>>> {
  return http.get('/api/nongshang/summary', params)
}

/**
 * 农事汇总表格
 */
export function recordSummaryExcel(year: string): Promise<IResData<{ excel_path: string }>> {
  return http.get('/api/nongshang/summary_excel', { year })
}
